package com.yiqi.zhiyuan.feature.order.view.adapter;

import android.text.TextUtils;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suozhang.framework.utils.DateUtil;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.common.utils.OrderUtil;
import com.yiqi.zhiyuan.entity.enums.OrderFlagType;
import com.yiqi.zhiyuan.entity.enums.OrderTabType;
import com.yiqi.zhiyuan.entity.enums.OrderType;
import com.yiqi.zhiyuan.entity.vo.OrderVO;

import static com.suozhang.framework.utils.DateUtil.FORMAT_YYYY_MM_DD_HH_MM3;


/**
 * @ProjectName: ZhiYuan
 * @Description: java类作用描述
 * @Author: lijuwen
 * @CreateDate: 2019/3/15 10:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/15 10:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class OrderAdapter extends BaseQuickAdapter<OrderVO, BaseViewHolder> {
    private int type;

    public OrderAdapter(int mType) {
        super(R.layout.item_order);
        this.type = mType;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderVO item) {

        helper.setText(R.id.tv_order_state, OrderTabType.getName(type))
                .setText(R.id.tv_order_use_type, OrderUtil.getOrderTypeString(item))
                .setText(R.id.tv_order_start_address, String.format("出发地点\t\t\t%s", item.getDeparture()))
                .setText(R.id.tv_order_end_address, String.format("目标地点\t\t\t%s", item.getDestination()))
                .setText(R.id.tv_order_time, OrderUtil.getOrderTypeDate(item))
                .setText(R.id.tv_order_point_1, TextUtils.isEmpty(item.getWaypoint1()) ? "" : "途径 地点\t\t"+item.getWaypoint1())
                .setText(R.id.tv_order_point_2, TextUtils.isEmpty(item.getWaypoint2()) ? "" : "途径地点\t\t"+item.getWaypoint2())
        ;

        helper.getView(R.id.tv_order_point_1).setVisibility(TextUtils.isEmpty(item.getWaypoint1()) ? View.GONE : View.VISIBLE);
        helper.getView(R.id.tv_order_point_2).setVisibility(TextUtils.isEmpty(item.getWaypoint2()) ? View.GONE : View.VISIBLE);
    }
}
